<!DOCTYPE html>
<html>
    <head>
    <link rel="stylesheet" type="text/css" href="css/Home.css" />
    <title>Home</title>
    <link rel="stylesheet" type="text/css" href="engine1/style.css" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    <meta name="keywords" content="WOW Slider, Wordpress Gallery Slider, Wordpress Photo Slider" />
    <meta name="description" content="WOWSlider created with WOW Slider, a free wizard program that helps you easily generate beautiful web slideshow" />
    <script language="javascript" type="text/javascript" src="engine1/jquery.js"></script>

    </head>
    
<?php include_once('master_menu.php');?>

<div class="page">
  <div class="left">
    <div class="chude">
      <div id="tieude">
        <div id="t1"><img src="images/audio_headphones.png" /><b>Việt Nam</b></div>
        <div class="tieude">
          <ul>
            <?php
                $conn = mysql_connect("localhost", "root","123456") or die("Ket noi den MySQL that bai");
                mysql_select_db("mp3", $conn);
                mysql_query("SET NAMES UTF8",$conn);
                $sql = "select * from `nghesi` where quoctich='Việt Nam';";
                $q = mysql_query($sql);
                while ($row= mysql_fetch_array($q))
                {
                    $nghesi=$row["nghedanh"];
                    $id=$row["id_nghesi"];
            ?>
            <li><a href="artist_page.php?id=<?=$id?>"><?=$nghesi?></a></li>
            <?php
            
                }
            ?>
          </ul>
        </div>
      </div>
    </div>
    <div class="chude">
      <div id="tieude">
        <div id="t1"><img src="images/audio_headphones.png" /><b>US-UK</b></div>
        <div class="tieude">
          <ul>
             <?php
                $sql = "select * from `nghesi` where quoctich like 'United%';";
                $q = mysql_query($sql);
                while ($row= mysql_fetch_array($q))
                {
                    $nghesi=$row["nghedanh"];
                    $id=$row["id_nghesi"];
            ?>
                <li><a href="artist_page.php?id=<?=$id?>"><?=$nghesi?></a></li>
            <?php
                }
            ?>
          </ul>
        </div>
      </div>
    </div>
    <div class="chude">
      <div id="tieude">
        <div id="t1"><img src="images/audio_headphones.png" /><b>Châu Á</b></div>
        <div class="tieude">
          <ul>
             <?php
                $sql = "select * from `nghesi` where quoctich like 'United%';";
                $q = mysql_query($sql);
                while ($row= mysql_fetch_array($q))
                {
                    $nghesi=$row["nghedanh"];
                    $id=$row["id_nghesi"];
            ?>
                <li><a href="artist_page.php?id=<?=$id?>"><?=$nghesi?></a></li>
            <?php
                }
             ?>
          </ul>
        </div>
      </div>
    </div>
  </div>
  <div class="content">
    
   
    <div class="toplist">
           <?php
      if(isset($_POST["sub"]))
      {
        $txt=$_POST["txt"];
        $t=$_POST["tim"];
        
        if(strcmp($t,"BÀI HÁT")== "BÀI HÁT" )
        {
            if(!empty($txt))
            {
                
                $sql=mysql_query("select * from music_nghesi 
                inner join music on music_nghesi.id_music=music.id_music
                inner join nghesi on music_nghesi.id_nghesi=nghesi.id_nghesi
                where upper(tenmusic) like '%".$txt."%' and music.loai = 0");
                while($row=mysql_fetch_array($sql))
                {
                  $tenbh=$row["tenmusic"]; 
                  $baihat=$row["id_music"];
                  $id=$row["id_nghesi"];
                  $link=$row["link"];
		  ?>
                       
       <form class="toplist1" action="" method="post">
        <h3><a href="chitietbh.php?id=<?=$baihat?>&idcs=<?=$id?>"><?=$tenbh?></a></h3>
        <p>Trình bày: <a href="artist_page.php?id=<?=$id?>"><?=$tencs?></a> | Lượt nghe:<?=$view?></p>
        <?php 

            if(isset($_SESSION["login"])&& $_SESSION["login"]!=NULL)
            {
               echo ("<div class='iconlist'>". 
                    "<a class='icondownload' href=nhac/".$link.">&emsp;&emsp;</a>".
                    "<input type='submit' class='iconadd' value='' /><input type='hidden' name='hid' value='$baihat'/>".
                    "<select class='selectpl' name='id$baihat'>");
                $sq = mysql_query("select a.* from playlist a, user b where  b.id_user=a.id_user and b.username= '".$_SESSION["login"]."'");
                while ($row= mysql_fetch_array($sq))
                {
                    $ten=$row["tenplaylist"]; 
                    $id_pl=$row["id_playlist"]; 
                             
                 echo("<option value='$id_pl'>$ten</option>");
                   
                }
                echo ("</select>".
                    "</div>");
            }
        ?>

      </form>
      <?php  
                }
				 if(isset($_POST['hid']))
            {
            $bh=$_POST['hid'];
            $sel=$_POST["id$bh"];
            $str = "call insertms_pl(" . $bh . "," . $sel . ")";
            $r=mysql_query($str);
            //$result=mysql_fetch_row($r);//lấy id của playlist mới add vào
			}
            }
            else
            {
                echo "Không tìm thấy";
            }
        }
        
        
        
        if(strcmp($t,"ALBUM")== "ALBUM")
       {
           if(!empty($txt))
            {
    	       $sql=mysql_query("select * from album
                where upper(tenalbum) like '%".$txt."%'");
                while($row=mysql_fetch_array($sql))
                {
                    $tenab=$row[1];
                    echo '<a href="#">'.$tenab.'</a>'."<br/>";
						
                }
            }
            else
            {
                echo "Không tìm thấy";
            }
       }


       if(strcmp($t, "VIDEO") == 'VIDEO')
       {
    	   if(!empty($txt))
            {
    	       $sql=mysql_query("select * from music where upper(tenmusic) like '%".$txt."%' and loai=1");
                while($row=mysql_fetch_array($sql))
                {
                    $tenbh=$row[2];
                    echo "<a href='#'>".$tenbh."</a>";
                }
            }
            else
            {
                echo "Không tìm thấy";
            }
       }

     
       if(strcmp($t,"NGHỆ SĨ")== "NGHỆ SĨ")
       {
    	   if(!empty($txt))
            {
    	       $sql=mysql_query("select * from nghesi where upper(nghedanh) like '%".$txt."%'");
                while($row=mysql_fetch_array($sql))
                {
                    $tenns=$row[2];
                     echo '<a href="#">'.$tenns.'</a>'."<br/>";
                }
            }
            else
            {
                echo "Không tìm thấy";
            }
        }
      
      
}
      ?>
    
      
      
      
    </div>
  </div>
<?php include_once('master_quangcao.php');?>
</div>
<?php include_once('master_footer.php');?>
</html>